package com.wcx.application.controller;


import com.wcx.application.config.MyCustomAnnotation;
import com.wcx.application.service.CollectionBossService;
import com.wcx.application.service.CollectionService;
import com.wcx.application.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/collectionBoss")
@ResponseBody
public class CollectionBossController {
    @Autowired
    private CollectionBossService collectionBossService;
    @MyCustomAnnotation
    @GetMapping("/insert")
    public Result insert(String fromId,String jobId) {
        int  i = collectionBossService.insert(fromId, jobId);
//        16
        if(i!=0){
            return  Result.ok();
        }else{
            return Result.error();
        }
    }

    @GetMapping("/delete")
    public Result delete(String fromId,String jobId) {
        int  i = collectionBossService.delete(fromId, jobId);
        if(i!=0){
            return  Result.ok();
        }else{
            return Result.error();
        }
    }

    @GetMapping("/search")
    public Result search(String fromId,String jobId) {
        return Result.ok().data("list", collectionBossService.search(fromId,jobId));
    }

    @GetMapping("/list")
    public Result list(String fromId) {
        return Result.ok().data("list", collectionBossService.list(fromId));
    }
}